Some modern electronic devices, such as, for example, microprocessors, microcontrollers, video processors, ASICS, etc., are equipped with scanning circuits to allow other circuits that interface with these devices either to scan out the internal state of the device, or to scan in an initial internal state. Such scanning circuits are particularly useful during the development of the device itself to provide information for de-bugging purposes. After the device has been developed, scanning circuits are useful for loading an initial state into the device during production testing. Such circuits are also useful for de-bugging and testing a larger system that uses the device as one component of the system.
Many devices have an internal clock divider that divides an input clock signal by a predetermined number and produces an output clock that comprises the divided down input clock. A common technique for implementing a scan feature for a device is to suspend the operation of the device's clock in response to a scan request. The scan request may be implemented using one or more control signals applied as inputs to the device. Then, after the clock has been safely stopped, it may be restarted for use in the scanning operation. At the conclusion of the scanning operation, the clock is again stopped, the control signals are removed, and the clock is then restarted.
This technique suffers from a major problem. When the clock is restarted after the scan operation, the state of the device's internal clock divider may be different from the state following the state it was in when the clock was stopped to initiate the scan operation. In other words, if the clock stopped in state X, it might restart in a state other than X+1. If the clock is restarted with the divider in an improper state, then the device may malfunction because these devices often carry out internal operations during each state of the clock divider. Restarting the clock in an improper state after a scan operation may cause various internal operations either to be skipped or erroneously performed twice. Either event can cause a device malfunction.